package com.example.sqliteframe;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;

public class MainActivity extends AppCompatActivity {
    String tableName="sql";
    Mytest []mytest={new Mytest("anan",18,"15707254047"),
                     new Mytest("bnbn",20,"15703044048"),
                     new Mytest("cncn",19,"15707252037")};
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }
    public void clickCreateDB(View view){
        AnanFrame.CreateDB(MainActivity.this,tableName,mytest[0].getClass());
    }
    public void clickInsertDB(View view){
        for(int i=0;i<3;i++) {
            AnanFrame.InsertDB(MainActivity.this, tableName, mytest[i]);
        }
    }
    public void clickQueryDB(View view){
        AnanFrame.QuaryDB(MainActivity.this,tableName,mytest[0].getClass());
    }
    public void clickDeleteDB(View view){
        //删除一条
        AnanFrame.DeleteDB( MainActivity.this,tableName,"name",mytest[1].name);
        //删除所有
//        AnanFrame.DeleteDB( MainActivity.this,tableName,null,null);
    }
    public void clickUpdateDB(View view){
        Mytest mytest4=new Mytest("cncn",21,"157003044047");
        AnanFrame.UpdateDB(MainActivity.this,tableName,mytest4,"name","cncn");
    }
}

class Mytest {
    String name;
    int age;
    String phone;
    Mytest(String _name,int _age,String _phone){
        this.name=_name;
        this.age=_age;
        this.phone=_phone;
    }
}